<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    本例演示了WebAssembly最原生的用法
    请查看控制台
    <script>
        //wasmCode其实就是native.wat对应的native.wasm的二进制串
        var wasmCode = new Uint8Array([0,97,115,109,1,0,0,0,1,144,128,128,128,0,3,96,0,1,127,96,2,127,127,1,127,96,1,127,1,127,3,132,128,128,128,0,3,0,1,2,4,132,128,128,128,0,1,112,0,0,5,131,128,128,128,0,1,0,1,6,129,128,128,128,0,0,7,163,128,128,128,0,4,6,109,101,109,111,114,121,2,0,4,109,97,105,110,0,0,3,115,117,109,0,1,9,103,101,116,83,116,114,105,110,103,0,2,10,159,128,128,128,0,3,132,128,128,128,0,0,65,42,11,135,128,128,128,0,0,32,1,32,0,106,11,132,128,128,128,0,0,32,0,11]);
        var wasmImports = {//一个将被导入到新创建实例中的对象，它包含的值有函数、WebAssembly.Memory 对象等等。编译的模块中，对于每一个导入的值都要有一个与其匹配的属性与之相对应，否则将会抛出 WebAssembly.LinkError

        };
        var wasmModule = new WebAssembly.Module(wasmCode);
        var wasmInstance = new WebAssembly.Instance(wasmModule, wasmImports);
        console.log(wasmInstance.exports.main());//42
        console.log(wasmInstance.exports.sum(3,2));//5
        // alert('检查控制台');


    
    </script>
</body>
</html>